import Vue from "vue";
import App from "./App.vue";
import { registerMicroApps, start } from "qiankun";
import microApps from "./micro_app";

Vue.config.productionTip = false;
window.projectName = "main"; // 为了测试沙盒环境

new Vue({
  render: (h) => h(App),
}).$mount("#app");

// 注册子应用
registerMicroApps(microApps, {
  beforeLoad: (app) => {
    console.log("before load app.name====>>>>>", app.name);
  },
  beforeMount: [
    (app) => {
      console.log("[LifeCycle] before mount %c%s", "color: green;", app.name);
    },
  ],
  afterMount: [
    (app) => {
      console.log("[LifeCycle] after mount %c%s", "color: green;", app.name);
    },
  ],
  afterUnmount: [
    (app) => {
      console.log("[LifeCycle] after unmount %c%s", "color: green;", app.name);
    },
  ],
  // 添加异常处理 ↓↓↓
  errorCapture: (err) => {
    console.error('微应用加载错误:', err)
    return true // 阻止错误继续向上传播
  }
});
// 启动qiankun
start({
  prefetch: false, // 关闭预加载
  sandbox: {
    strictStyleIsolation: true // 启用严格的样式隔离
  }
});
